package com.rxw.nutmall.product.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.rxw.nutmall.exception.validated.AddGroup;
import com.rxw.nutmall.exception.validated.UpdateGroup;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;
import java.io.Serializable;

/**
 * <p>
 * 品牌
 * </p>
 *
 * @author 咸蛋超人
 * @since 2023-12-24
 */
@Getter
@Setter
@TableName("pms_brand")
@ApiModel(value = "Brand对象", description = "品牌")
public class Brand implements Serializable {

    private static final long serialVersionUID = 1L;

    @NotNull(message = "品牌id不能为空", groups = {UpdateGroup.class})
    @Null(message = "品牌id必须为空", groups = {AddGroup.class})
    @ApiModelProperty("品牌id")
    @TableId(value = "brand_id", type = IdType.ASSIGN_ID)
    private Long brandId;

    @ApiModelProperty("品牌名")
    @TableField("name")
    @NotBlank(message = "品牌名不能为空", groups = {AddGroup.class, UpdateGroup.class})
    private String name;

    @ApiModelProperty("品牌logo地址")
    @TableField("logo")
    @NotEmpty(groups = {AddGroup.class})
    @URL(message = "logo必须是一个url地址", groups = {AddGroup.class, UpdateGroup.class})
    private String logo;

    @ApiModelProperty("介绍")
    @TableField("descript")
    private String descript;

    @ApiModelProperty("显示状态[0-不显示；1-显示]")
    @TableField("show_status")
    @NotNull(groups = {AddGroup.class})
    @Min(value = 0, groups = {AddGroup.class, UpdateGroup.class})
    @Max(value = 1, groups = {AddGroup.class, UpdateGroup.class})
    private Byte showStatus;

    @ApiModelProperty("检索首字母")
    @TableField("first_letter")
    @NotEmpty(groups = {AddGroup.class})
    @Pattern(regexp = "^[a-zA-Z]$", message = "检索首字母必须是一个字母", groups = {AddGroup.class, UpdateGroup.class})
    private String firstLetter;

    @ApiModelProperty("排序")
    @TableField("sort")
    @NotNull(groups = {AddGroup.class})
    @Min(value = 0, message = "排序必须是一个正整数", groups = {AddGroup.class, UpdateGroup.class})
    private Integer sort;
}
